{include file="common/head"/}
<link rel="stylesheet" href="__STATIC__/plugins/spectrum/spectrum.css">
<style>
    .edui-editor{z-index: 1!important;}
</style>
<script>
    var ADMIN = '__ADMIN__';
    var UPURL = "{:url('UpFiles/upImages')}";
    var PUBLIC = "__PUBLIC__";
    var imgClassName,fileClassName;
</script>
{include file="common/foot"/}
<script src="__STATIC__/common/js/jquery.2.1.1.min.js"></script>
<script>
    var edittext=new Array();
</script>
<script src="__STATIC__/ueditor/ueditor.config.js" type="text/javascript"></script>
<script src="__STATIC__/ueditor/ueditor.all.min.js" type="text/javascript"></script>
<div class="admin-main layui-anim layui-anim-upbit">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>{$title}</legend>
    </fieldset>
    <form class="layui-form" method="post">
        <input type="hidden" name="service_id" value="{$service_id}">
        <div class="layui-form-item layui-col-lg4 layui-col-xs24">
            <label class="layui-form-label">提供方名称</label>
            <div class="layui-input-block">
                <input type="text" name="title" required  placeholder="提供方名称" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item layui-col-lg4 layui-col-xs24">
            <label class="layui-form-label">排序</label>
            <div class="layui-input-block">
                <input type="text" name="listorder" value="50"   placeholder="排序" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item layui-col-lg4 layui-col-xs24">
            <label class="layui-form-label">qq</label>
            <div class="layui-input-block">
                <input type="text" name="qq"  placeholder="qq" autocomplete="off" class="layui-input">
            </div>
        </div>


        <div class="layui-form-item layui-col-lg4 layui-col-xs24">
            <label class="layui-form-label">微信</label>
            <div class="layui-input-block">
                <input type="text" name="wx"  placeholder="微信" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item layui-col-lg4 layui-col-xs24">
            <label class="layui-form-label">手机号</label>
            <div class="layui-input-block">
                <input type="text" name="mobile"  placeholder="手机号" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item layui-col-lg4 layui-col-xs24">
            <label class="layui-form-label">简介</label>
            <div class="layui-input-block">
                <input type="text" name="intro"  placeholder="简介" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item"><label class="layui-form-label">缩略图</label>
            <div class="layui-input-4"><input type="hidden" name="qr" id="thumb" value="">
                <div class="layui-upload">
                    <button type="button" class="layui-btn layui-btn-primary" id="thumbBtn"><i
                            class="icon icon-upload3"></i>点击上传
                    </button>
                    <div class="layui-upload-list"><img class="layui-upload-img" id="cltThumb"
                                                        src="/static/admin/images/tong.png">
                        <p id="thumbText"></p></div>
                </div>
            </div>
        </div>


            <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="button" class="layui-btn" lay-submit="" lay-filter="submit">{:lang('submit')}</button>
                {if condition="MODULE_NAME eq 'page'"}
                <a href="{:url('category/index')}" class="layui-btn layui-btn-primary">{:lang('back')}</a>
                {else /}
                <a href="{:url('index',['catid'=>input('catid')])}" class="layui-btn layui-btn-primary">{:lang('back')}</a>
                {/if}
            </div>
        </div>
    </form>
</div>
<script src='__STATIC__/plugins/spectrum/spectrum.js'></script>
<script src='__ADMIN__/js/edit.js'></script>
<script src='__STATIC__/common/js/layui-mz-min.js'></script>
<script>
    var url = '{:url("article_add")}';
            layui.use(['form','upload','layedit','laydate','jquery'], function () {

                var form = layui.form,upload = layui.upload,layedit = layui.layedit,laydate = layui.laydate,$ = layui.jquery;

                layui.selMeltiple($);
                //缩略图上传
                upload.render({
                    elem: '#thumbBtn'
                    ,url: '{:url("UpFiles/upload")}'
                    ,accept: 'images' //普通文件
                    ,exts: 'jpg|png|gif' //只允许上传压缩文件
                    ,done: function(res){
                        console.log(res);
                        $('#cltThumb').attr('src', res.url);
                        $('#thumb').val(res.url);
                    }
                });
                form.on('submit(submit)', function (data) {
                    if(edittext){
                        for (key in edittext){
                            data.field[key] = $(window.frames["LAY_layedit_"+edittext[key]].document).find('body').html();
                        }
                    }
                    var images='';
                    $(".imgVal").each(function(i) {
                        images+=$(this).val()+';';
                    });
                    $.post(url, data.field, function (res) {
                        if (res.code > 0) {
                            layer.msg(res.msg, {time: 1800, icon: 1}, function () {
                                location.href = res.url;
                            });
                        } else {
                            layer.msg(res.msg, {time: 1800, icon: 2});
                        }
                    });
                });

            });

</script>
